<?php

namespace app\common\resourceHandle;

use app\common\model\OrderComment;
use think\Model;

class OrderCommentResource extends ResourceHandle
{

    /**
     * @param Model $model
     * @return array
     * @throws \think\Exception
     */
    public function handle(Model $model): array
    {
        $comment = $model->toArray();
        // 评论匿名处理
        if ($comment['anonymous'] === OrderComment::IS_ANONYMOUS) {
            $comment['member']['member_name']   = '匿名';
            $comment['member']['member_mobile'] = '';
            $comment['member']['member_avatar'] = '';
        }
        return $comment;
    }
}